<template>
  <!-- 添加或修改自动打招呼对话框 -->
  <el-dialog :close-on-click-modal="false" :title="formType" :visible.sync="open" @close="cancel"
             width="600px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="回复内容" prop="content">
            <el-input v-model="form.content" placeholder="请输入回复内容"
                      type="textarea"
                      :rows="2"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="针对性别" prop="atSex">
            <el-select v-model="form.atSex" placeholder="请选择发送方性别">
              <el-option
                v-for="dict in atSexOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import operationModule from '@/mixins/operation-module'
  import {
    addAutogreet,
    updateAutogreet
  } from "@/api/chatnotify/autogreet";

  export default {
    name: 'add-or-update',
    mixins: [operationModule],
    data() {
      return {
        // 设置属性
        mixinOperationModuleOptions: {
          saveURL: addAutogreet, // 提交数据接口，api地址
          updateURL: updateAutogreet // 提交数据接口，api地址
        },
        moduleName: "Autogreet",
        open: false,
        // 弹出层标题
        //表单操作类型
        formType: this.$formType.add,
        // 表单参数
        form: {},
        // 针对性别 1=男,2=女字典
        atSexOptions: [],
        // 表单校验
        rules: {}
      }
    },
    methods: {
      init(type) {
        this.reset()
        this.open = true
        if (type == this.$formType.add) {
        } else if (type == this.$formType.edit) {
        } else if (type == this.$formType.detail) {
        }
        this.formType = type
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          content: undefined,
          atSex: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          remark: undefined
        }
        ;
        this.resetForm("form");
      },
      cancel() {
        this.$emit('on-close')
        this.open = false;
      }
    },
    created() {
      this.reset();
    }
  }
</script>
